import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useGlobalStore = defineStore('global', () => {
  // 已连接的设备列表
  const connDeviceList = ref([])
  // 添加已连接的设备
  const addConnDeviceList = (deviceId) => {
    connDeviceList.value.push(deviceId)
  }
  // 移除已连接的设备
  const removeConnDeviceList = (deviceId) => {
    connDeviceList.value = connDeviceList.value.filter((id) => id !== deviceId)
  }

  return {
    connDeviceList,
    addConnDeviceList,
    removeConnDeviceList,
  }
})
